<template>
	<view class="custom_pay">
		<view
			class="status_bar_h"
			:style="{
				height: `${statusBarHeight}px`,
				backgroundColor: '#20BF6C',
			}"></view>
		<view class="web_view">
			<web-view src="/hybrid/html/pay.html"></web-view>
		</view>
	</view>
</template>

<script>
import useStore from '@/store/index.js';
import baseURL from '@/utils/baseURL.js';
export default {
	components: {},
	data() {
		return {
			baseURL,
			isChecked: false,
			disabled: false,
			isCouponShow: false,
			changeText: '获取验证码',
			view: {
				ticket: {},
				user: {},
				store: '',
				coupon: '',
				count: 0,
				couponMoney: 0,
			},
			form: {},
			statusBarHeight: 0, // 顶部状态栏高度
			bthHeight: 0, // 底部按钮高度
			list: [],
			options: {
				coupon: [],
			},
			scrollTop: 0,
			old: {
				scrollTop: 0,
			},
			page: 1,
			timer: null,
		};
	},
	onLoad() {
		this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
		const screenTop = uni.getSystemInfoSync().safeArea.top;
		const screenBot = uni.getSystemInfoSync().safeArea.bottom;
		this.bthHeight = uni.getSystemInfoSync().screenHeight - (1000 - 40) / 2;
		this.countdown();
		// const token = JSON.parse(uni.getStorageSync('token'))
		// 	? JSON.parse(uni.getStorageSync('token'))
		// 	: ''; // 1 店家 2商家
		// if (!token) {
		// 	uni.navigateTo({
		// 		url: '/pages/login/login',
		// 	});
		// } else {
		// }
	},
	onUnload() {
		clearTimeout(this.timer);
	},
	methods: {
		countdown() {
			this.timer = setTimeout(() => {
				uni.navigateTo({
					url: '/pages/index/index',
				});
			}, 1000 * 60 * 10);
		},
		clearCountdown() {
			clearTimeout(this.timer);
			this.countdown();
		},

		submit() {},
		checkForm() {
			const { user_name, user_pass } = this.form;
			return user_name && user_pass ? true : false;
		},

		close() {
			this.isCouponShow = false;
		},
		jump(data) {
			let url = '';
			switch (data) {
				case 'register':
					url = '/pages/register/register';
					break;
				case 'codeLogin':
					url = '/pages/menu/menu';
					break;
				case 'scanCode':
					url = '/pages/scanCode/scanCode';
					break;
				case 'pay':
					url = '/pages/pay/ticket';
					break;
				case 'logout':
					url = '/pages/index/index';
					break;
				default:
			}
			uni.navigateTo({ url });
		},
		logout() {
			uni.removeStorageSync('userOptions');
			this.jump('logout');
		},
		handShopping() {
			console.log('购买');
		},
	},
};
</script>

<style lang="scss" scoped>
.custom_pay {
	position: fixed;
	top: 0;
	right: 0;
	z-index: 10;
	width: 100%;
	height: 400rpx;
	background-color: rgba(0, 0, 0, 0.5);
}
</style>
